package com.作业.Day3;
import java.util.Arrays;
import java.util.Scanner;
public class Homework8 {
    public static void main(String[] args) {
        String []a={"a","b","c","e","f","p","u","z"};
        System.out.print("原字符序列");
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]);
        }
        Scanner scanner = new Scanner(System.in);
        System.out.print("待插入的字符是");
        String m = scanner.next();
        char c = m.charAt(0);
        char []b=new char[9];
        //先将数组的全部字母转换为 ASCII码
        for (int i = 0; i < a.length; i++) {
           b[i] = a[i].charAt(0);
        }
        System.out.println(Arrays.toString(b));
        //比较
        for (int i =0; i <b.length ; i++) {
            if(b[i] > c){
                System.out.println("插入字符的下标:"+(i));
                for (int j =b.length-1 ; j >=i ; j--) {
                    b[j]=b[j-1];
                }
                 b[i]=c;
                break;
            }
        }
        System.out.println(Arrays.toString(b));
    }


}
